﻿CREATE TABLE [dbo].[Application] (
    [ApplicationId]		INT          IDENTITY (1, 1) NOT NULL,
    [Name]				VARCHAR (100) NOT NULL,
    [Title]				VARCHAR (150) NOT NULL,
    [EnterpriseId]		INT          CONSTRAINT [DF_Application_EnterpriseId] DEFAULT ((1)) NOT NULL,
    [Active]			bit          CONSTRAINT [DF_Application_Active]  NOT NULL DEFAULT 1,
    [Area]				VARCHAR (100) NULL, --MVC Application specific, I could have named this as UserField1 
    [DefaltController]	VARCHAR (100) NULL DEFAULT 'Home',	--MVC Application specific, I could have named this as UserField2 
    [DefaltAction]		VARCHAR (100) NULL DEFAULT 'Index', --MVC Application specific, I could have named this as UserField3 
    [adt_DateCreated] DATETIME     CONSTRAINT [DF_Application_adt_DateCreated] DEFAULT (getdate()) NOT NULL,
    [adt_CreatedBy]   VARCHAR (50) NULL,
    [DisplayOrder] INT  DEFAULT 1 NULL, 
    CONSTRAINT [PK_Application] PRIMARY KEY CLUSTERED ([ApplicationId] ASC),
    CONSTRAINT [FK_Application_Enterprise] FOREIGN KEY ([EnterpriseId]) REFERENCES [dbo].[Enterprise] ([EnterpriseId])
);


GO
CREATE UNIQUE NONCLUSTERED INDEX [IX_Application]
    ON [dbo].[Application]([Name] ASC, [EnterpriseId] ASC);

